<?php

declare(strict_types=1);
/**
 * This file is part of habo_new_media.
 *
 * @link     https://www.berlen.cn/
 * @contact  tech@berlen.cn
 * @license  http://gitlab.rehou.cn/habo/habo_new_media/-/blob/master/README.md
 */
namespace app\service\token;

use app\enum\CommonEnum;
use app\service\BaseService;
use app\service\token\media\KuaiShouEspService;
use app\service\token\media\KuaiShouService;
use app\service\token\media\OceanService;
use app\service\token\media\QqService;

final class TokenService extends BaseService
{
    private static array $handle = [];

    /**
     * 实例.
     */
    private function __construct()
    {
    }

    private function __clone()
    {
    }

    /**
     * 获取实例.
     * @param int $mediaId 媒体id
     * @return KuaiShouService|mixed|OceanService|QqService
     */
    public static function getInstance(int $mediaId = 0)
    {
        if (! isset(self::$handle[$mediaId])) {
            if ($mediaId == CommonEnum::OE_MEDIA) {
                self::$handle[$mediaId] = new OceanService();
            } elseif ($mediaId == CommonEnum::KS_MEDIA) {
                self::$handle[$mediaId] = new KuaiShouService();
            } elseif ($mediaId == CommonEnum::QQ_MEDIA) {
                self::$handle[$mediaId] = new QqService();
            } elseif ($mediaId == CommonEnum::KS_ESP_MEDIA) {
                self::$handle[$mediaId] = new KuaiShouEspService();
            }
        }
        return self::$handle[$mediaId];
    }
}
